package com.urbane.banner.listener;

import org.springframework.boot.context.event.*;
import org.springframework.context.ApplicationListener;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@Component
@Order(1)
public class CustomBannerListener implements ApplicationListener<SpringApplicationEvent> {
    @Override
    public void onApplicationEvent(SpringApplicationEvent event) {
        // 根据事件类型执行不同的逻辑
        switch (event) {
            case ApplicationStartingEvent applicationStartingEvent ->
                    System.out.println("1、CustomApplicationListener - 应用启动中");
            case ApplicationEnvironmentPreparedEvent applicationEnvironmentPreparedEvent ->
                    System.out.println("2、CustomApplicationListener - 环境准备完成");
            case ApplicationPreparedEvent applicationPreparedEvent ->
                    System.out.println("3、CustomApplicationListener - 应用准备完成");
            case ApplicationStartedEvent applicationStartedEvent ->
                    System.out.println("4、CustomApplicationListener - 应用已启动");
            case ApplicationReadyEvent applicationReadyEvent ->
                    System.out.println("5、CustomApplicationListener - 应用准备就绪");
            case ApplicationFailedEvent applicationFailedEvent ->
                    System.out.println("6、CustomApplicationListener - 应用启动失败");
            default -> {
                System.out.println("7、CustomApplicationListener - Hello World!");
            }
        }
    }
}
